package com.huike.clues.service.impl;

import com.huike.clues.domain.SysNotice;
import com.huike.clues.mapper.SysNoticeMapper;
import com.huike.clues.service.ISysNoticeService;
import com.huike.common.config.BaseContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class SysNoticeServiceImpl implements ISysNoticeService {
    @Autowired
    private SysNoticeMapper sysNoticeMappe;

    @Override
    public void update(Long noticeId) {
        sysNoticeMappe.updateStatus(noticeId);
    }

    @Override
    public SysNotice info(Long noticeId) {
        SysNotice sysNotice=sysNoticeMappe.info(noticeId);
        sysNotice.setNoticeUserId((BaseContext.getCurrentUser().getUserId()).toString());
        return sysNotice;
    }

    @Override
    public List<SysNotice> list(String status) {
        List<SysNotice> list = sysNoticeMappe.list(status);
        List<SysNotice> collect = list.stream().peek(o -> o.setNoticeUserId((BaseContext.getCurrentUser().getUserId()).toString())).collect(Collectors.toList());
        return collect;
    }
}
